package com.vansoftwaredesign.widgetlibrary;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Shader.TileMode;
import android.util.AttributeSet;
import android.view.View;

public class MainWindowView extends View {
	
	private Paint rimPaintInner = new Paint();
	private LinearGradient rimShaderInner;
	private Paint rimPaintOuter = new Paint();
	private LinearGradient rimShaderOuter;
	//private Paint rimPaintOuterLine = new Paint();
	private int measuredWidth;
	private int measuredHeight;
	
	public MainWindowView(Context context) {
		super(context);
		initView(null,null);
	}
	
	public MainWindowView(Context context, AttributeSet attrs) {
		super(context, attrs);
		initView(context,attrs);
	}

	public MainWindowView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		initView(context,attrs);
	}

	private void initView(Context context, AttributeSet attrs) {
		
		
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		
		//Set up the outer ring. Note: some hard coded values need to be changed to variables in this code
		rimShaderOuter = new LinearGradient(0, 0, measuredWidth, measuredHeight, Color.WHITE, Color.BLUE, TileMode.MIRROR);

		rimPaintOuter.setAntiAlias(true);
		rimPaintOuter.setStyle(Style.STROKE);
		rimPaintOuter.setStrokeWidth(10-2);
		rimPaintOuter.setShader(rimShaderOuter);
		canvas.drawRect(0,0,measuredWidth,measuredHeight,rimPaintOuter);
		//canvas.drawCircle(backgroundCircleX, backgroundCircleY, backgroundCircleRadius+(rimWidth/2), rimPaintOuter);

		rimShaderInner = new LinearGradient(0, 0, measuredWidth, measuredHeight, Color.BLUE, Color.WHITE, TileMode.MIRROR);

		rimPaintInner.setAntiAlias(true);
		rimPaintInner.setStyle(Style.STROKE);
		rimPaintInner.setStrokeWidth(6);
		rimPaintInner.setShader(rimShaderInner);
		canvas.drawRect(0,0,measuredWidth,measuredHeight,rimPaintInner);
		//canvas.drawCircle(backgroundCircleX, backgroundCircleY, backgroundCircleRadius+(1), rimPaintInner);
	}

	@Override
	protected void onLayout(boolean changed, int left, int top, int right,int bottom) {
		super.onLayout(changed, left, top, right, bottom);
		
		measuredWidth  = getMeasuredWidth();
		measuredHeight = getMeasuredHeight();
	}
	
	


}
